package com.hzsai.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;

/**
 * @author: hzsai
 * @date : 2020/3/20
 * usage:
 **/
@Configuration
public class ThreadPoolTaskSchedulerConfig {

    @Primary
    @Bean("threadxPoolTaskScheduler")
    public ThreadPoolTaskScheduler threadxPoolTaskScheduler() {
        ThreadPoolTaskScheduler taskScheduler = new ThreadPoolTaskScheduler();
        taskScheduler.setPoolSize(5);
        taskScheduler.setThreadNamePrefix("ThreadxPoolTaskScheduler-");
        return taskScheduler;
    }
}
